package com.example.erhuo.fragment;

import androidx.lifecycle.ViewModel;

import com.example.erhuo.PersonInformation;
import com.example.erhuo.R;
import com.example.erhuo.adapter.GoodAdapter;

public class MyViewModel extends ViewModel {
    private PersonInformation personInformation = new PersonInformation();
    //private GoodAdapter goodAdapter;

    // TODO: Implement the ViewModel

    @Override
    protected void onCleared() {
        personInformation = null;
        super.onCleared();
    }

    public boolean userIsLogin() {
        return personInformation.isLogin();
    }

    public String getUsername() {
        if (personInformation.getUserName() == null || personInformation.getUserName().equals("")) {
            return "请登录！";
        }
        return personInformation.getUserName();
    }

    public String getStudentId() {
        if (personInformation.getStudentId() == null || personInformation.getStudentId().equals("")) {
            return "学号:xxxxxxxx";
        }
        return "学号:" + personInformation.getStudentId();
    }

    public void setPersonInformation(PersonInformation personInformation) {
        this.personInformation = personInformation;
    }

    public String getToken() {
        return personInformation.getCookie();
    }


}